package org.scau.studentevaluation.entity.dos;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 *
 * </p>
 *
 * @author x1aolone
 * @since 2020-08-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("rules")
public class RulesDO implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("rule")
    private String rule;

    @TableField("subject")
    private Integer subject;

    @TableField("college")
    private String college;

    @TableField("year")
    private Integer year;

    // lyl增加
    @TableField("rule_id")
    private Integer ruleId;


    /**
     * 内部类
     * 用于去重操作
     * @Author: lyl
     */
    @AllArgsConstructor
    @Data
    public class CollegeAndYear{
        Integer year;
        String college;

        @Override
        public boolean equals(Object obj) {
            CollegeAndYear other = (CollegeAndYear) obj;
            return other.year.equals(this.year) && other.college.equals(this.college);
        }

        @Override
        public int hashCode() {
            return college != null ? college.hashCode():0;
        }
    }

    /**
     * 配合内部类，用于stream().map()
     * @return
     */
    public CollegeAndYear getCollegeAndYear(){
        return new CollegeAndYear(year,college);
    }


}